package org.text2diagram.ddl.domain;
public class LinkKey {
	
	private Block source;
	private Block target;
	private String text;
	
	public LinkKey() {
	}
	
	public LinkKey(String text, Block source, Block target) {
		super();
		this.source = source;
		this.target = target;
		this.text = text;
	}
	
	public LinkKey(Link link) {
		super();
		this.source = link.getSource();
		this.target = link.getTarget();
		this.text = link.getText();
	}	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((source == null) ? 0 : source.hashCode());
		result = prime * result
				+ ((target == null) ? 0 : target.hashCode());
		result = prime * result + ((text == null) ? 0 : text.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LinkKey other = (LinkKey) obj;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		if (target == null) {
			if (other.target != null)
				return false;
		} else if (!target.equals(other.target))
			return false;
		if (text == null) {
			if (other.text != null)
				return false;
		} else if (!text.equals(other.text))
			return false;
		return true;
	}
	
	public Block getSource() {
		return source;
	}
	
	public void setSource(Block source) {
		this.source = source;
	}
	
	public Block getTarget() {
		return target;
	}
	
	public void setTarget(Block target) {
		this.target = target;
	}
	
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}
	
}
